/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tabelmodel;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import model.EfekSamping;

/**
 *
 * @author Asus
 */
public class EfekSampingTerpilihTableModel extends AbstractTableModel {

    private List<EfekSamping> efek = new ArrayList<EfekSamping>();

    public EfekSampingTerpilihTableModel(List<EfekSamping> efek) {
        this.efek = efek;
    }

    public void deleteEfek(int row){
        efek.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void updateEfek(int row, EfekSamping efekk){
        efek.set(row,efekk);
        fireTableRowsUpdated(row, row);
    }

    public void addEfek(EfekSamping efekk) {
        efek.add(efekk);
        fireTableRowsInserted(getRowCount() - 1, getColumnCount() - 1);
    }

    public int getRowCount() {
        return efek.size();
    }


    public int getColumnCount() {
        return 1;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        EfekSamping b = efek.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return b.getNamaEfekSamping();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "EFEK SAMPING";
            default:
                return "";
        }
    }
}

